const express = require("express")
const route = express.Router();
const advModel = require("../db/model/advModel")
const isLoginMiddle = require('../middleware/isLoginMiddle')

//写个接口，使用封装好的权限验证中间件
route.get("/advList", isLoginMiddle, async (req, res) => {
  //查询数据库广告的集合
  try{
   const findResult = await advModel.find({});
   res.send({
    code :10000,
    msg : "查询成功",
    data :findResult
   })
  }catch(e){
    console.log("查询广告类别异常："+e.message);
    res.send({
        code : 10002,
        msg : "查询广告异常："+ e.message,
        data : null

    })
  }
})
module.exports = route;